package sample.chapter7.polling;

import java.util.NavigableSet;
import java.util.TreeSet;

/**
 * A sample class demonstrating polling
 * 
 * @author kan.sun
 *
 */
public class Polling
{
	public static void main(String[] args)
	{
		NavigableSet<Integer> times = new TreeSet<Integer>();
		times.add(1205);
		times.add(1505);
		times.add(1545);
		times.add(1600);
		times.add(1830);
		times.add(2000);
		times.add(2010);
		times.add(2100);
		
		System.out.println("The original set. ");
		for(int i:times)
		{
			System.out.println(i);
		}
		
		int removedHead = times.pollFirst();
		System.out.println("\nHead "+removedHead+" is removed from set. ");
		for(int i:times)
		{
			System.out.println(i);
		}
		
		int removedTail = times.pollLast();
		System.out.println("\nTail "+removedTail+" is removed from set. ");
		for(int i:times)
		{
			System.out.println(i);
		}
	}
}
